<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>首页 </title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <link href="css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
    <link href="css/materialdesignicons.min.css"  th:href="@{/css/materialdesignicons.min.css}" rel="stylesheet">
    <link href="css/style.min.css" th:href="@{/css/style.min.css}" rel="stylesheet"></head>

<body>
<div class="lyear-layout-web" id="mainContent">
    <div  th:if="${session.grade} eq 3">
        <div th:replace="~{main::rightbar}"></div>
    </div>
    <div  th:if="${session.grade} eq 1">
        <div th:replace="~{kfmain::kfrightbar}"></div>
    </div>
    <div  th:if="${session.grade} eq 2">
        <div th:replace="~{csmain::csrightbar}"></div>
    </div>
    <div th:replace="~{main::topbar}"></div>
    <div class="lyear-layout-container">

        <header class="lyear-layout-header" th:fragment="topbar">

            <nav class="navbar navbar-default">
                <div class="topbar">

                    <div class="topbar-left">
                        <div class="lyear-aside-toggler">
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                        </div>
                        <span class="navbar-page-title"> 文件管理 </span>
                    </div>
                    <div th:replace="~{main::bar}"></div>


                </div>
            </nav>

        </header>

        <main class="lyear-layout-content">


            <div class="container-fluid">



                <div class="row">

                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-header">
                                <h4>文件日志</h4>
                            </div>
                            <div class="card-body">


                                <div class="table-responsive">
                                    <table class="table table-hover" >
                                        <thead>
                                        <tr>
                                            <th>文件名称</th>
                                            <th>上传者姓名</th>
                                            <th>创建时间</th>
                                            <th>版本号</th>
                                            <th>文件描述</th>
                                            <th>是否为当前版本</th>
                                            <th>回退</th>
                                        </tr>
                                        </thead>
                                        <tbody id="boby">

                                        <!--<tr>
                                            <td>8</td>
                                            <td>Logo设计</td>
                                            <td>10/02/2019</td>
                                            <td>01/03/2019</td>
                                            <td><span class="label label-warning">完成</span></td>
                                            <td>
                                                <div class="progress progress-striped progress-sm">
                                                    <div class="progress-bar progress-bar-success" style="width: 100%;"></div>
                                                </div>
                                            </td>
                                        </tr>-->
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="js/main.min.js"></script>

<!--图表插件-->
<script type="text/javascript" src="js/Chart.js"></script>

<script type="text/javascript">
    //别忘了导入该用的js文件
    rizhilist();
    function getUrlVars()
    {
        var args=new Object();
        var query=location.search.substring(1);//获取查询串
        var pairs=query.split("&");//在逗号处断开
        for(var   i=0;i<pairs.length;i++)
        {
            var pos=pairs[i].indexOf('=');//查找name=value
            if(pos==-1)   continue;//如果没有找到就跳过
            var argname=pairs[i].substring(0,pos);//提取name
            var value=pairs[i].substring(pos+1);//提取value
            args[argname]=unescape(value);//存为属性
            console.log(args+"************");
        }
        return args;
    }

    function rizhilist() {

        var data1=getUrlVars();

        console.log(data1+"************");
        var list = getuserlist();
        console.log(list+"************list");
        $.ajax({
            type:'post',
            url:'/rizhilist',
            contentType: "application/json",

            scriptCharset: 'utf-8',

            datatype:"JSON",
            // data:user,
            //contentType:'application/json;charset=UTF-8',
            data:JSON.stringify(data1),
            async : true,
            // global:false,
                success:function (data) {
                    console.log(data)
                    var str1 = "";
                    //清空table中的html
                    $("#boby").html("");
                    for(var i = 0;i<data.length;i++){
                        str1 = "<tr>" +
                            "<td>"+data[i].name + "</td>" +
                            "<td>"+data[i].upname + "</td>" +
                            "<td>"+data[i].up + "</td>" +
                            "<td>"+data[i].edition+ "</td>" +
                            "<td>"+data[i].miaoshu+ "</td>" +
                            "<td>"+data[i].flag+ "</td>";
                        if(list.usergrade==3)
                        {
                            str1=str1+"<td>"+"<a onclick='huituifile("+"\""+data[i].edition+"\""+","+"\""+data[i].name+"\""+","+"\""+data[i].filepath+"\""+")'"+"style=' height: 21px;\n" +
                                "            line-height: 21px;\n" +
                                "            padding: 0 11px;\n" +
                                "            background-color: #33cabb;\n" +
                                "           border-color: #33cabb;\n" +
                                "            color: #fff!important;\n" +
                                "            border-radius: 3px;\n" +
                                "            display: inline-block;\n" +
                                "            text-decoration: none;\n" +
                                "            font-size: 12px;\n" +
                                "            outline: none;'>回退到此版本</a>"+"</td>" +
                                "</tr>";
                        }else {
                        str1=str1+"<td>"+"没有权限操作" + "</td>" +"</tr>";
                       }

                        $("#boby").append(str1);
                    }

            },
            error: function (data) {
                alert('操作失败');
            },
        });
    }
    function huituifile(a,b,c) {
        console.log(a);
        console.log(b);
        console.log(c)
        var data1={"name":b,"edition":a,"filepath":c};

        console.log(data1);
        $.ajax({
            type:'post',
            url:'/huituifile',
            contentType: "application/json",
            datatype:"JSON",
            // data:user,
            //contentType:'application/json;charset=UTF-8',
            data:JSON.stringify(data1),
            async : true,
            // global:false,
            success:function(json){
                alert('操作成功');
                subForm();

            },
            error: function (data) {
                alert('操作失败');
            },
        });
    }
    function getuserlist(){
        var a=[];
        $.ajax({
            type:'get',
            url:'/getuserlist',
            // data:user,
            //contentType:'application/json;charset=UTF-8',

            async : false,
            // global:false,
            success:function(json){
                console.log(json+"json")
                a = json;
            },

            error: function (data) {

            },
        });
        console.log(a+"************************")

        return a;

    }

</script>
</body>

</html>